import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
from selenium.webdriver.support.select import Select

testCase = "DBshop033_商品管理商品索引_更新"
firefox = openBrowser(url)
firefox.get(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox, "商品管理", "商品索引")

# 1.点击“点击更新商品索引”按钮，点击“保存索引设置”
firefox.find_element_by_xpath("//button[contains(.,'更新商品索引')]").click()
time.sleep(5)
# 处理js弹框
firefox.switch_to.alert.accept()  # 处理js弹框，点击确定按钮
time.sleep(2)
firefox.find_element_by_xpath("//button[contains(.,'保存索引设置')]").click()


try:
    firefox.find_element_by_xpath("//*[contains(text(),'商品索引设置成功！')]")
    writeLog("%s 测试通过" % testCase)
    print("测试通过")
except:
    print("测试失败")
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()